package com.chb.system.controller.apis;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chb.system.annotation.OperLogAnnotation;
import com.chb.system.service.RegisteredItemService;
import com.chb.system.vo.RegisteredItemVo;
import com.hos.entity.sys.RegisteredItem;
import com.hos.entity.sys.Role;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/12/12 15:51
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/system/api/registeredItem")
@Api(value = "挂号项目相关接口", tags = "挂号项目相关接口")
public class APIRegisteredItemController {

    @Autowired
    private RegisteredItemService registeredItemService;


    @GetMapping("/getAllRegisteredItem")
    @ApiOperation(value = "查询所有挂号信息列表")
    public Result<List<RegisteredItem>> getAllRegisteredItem() {
        return new Result<>(200, "查询成功", registeredItemService.getRegisteredItemAll());
    }

    @PostMapping("findRegisteredItemByCond")
    @ApiOperation(value = "条件查询挂号项目的信息")
    public Result<Page<RegisteredItem>> findRegisteredItemByCond(@RequestBody RegisteredItemVo registeredItemVo) {
        return new Result<>(200, "请求成功", registeredItemService.findRegisteredItemByCond(registeredItemVo));
    }


    @DeleteMapping("deleteRegisteredItemByRegisteredItemIds/{ids}")
    @ApiOperation(value = "根据挂号项目ID永久删除挂号项目")
    @OperLogAnnotation(business_type = "系统业务-删除挂号项目", operator_type = 1)
    public Result<Integer> deleteRegisteredItemByRegisteredItemIds(@PathVariable List<Long> ids) {
        return new Result<>(200, "删除成功", registeredItemService.deleteRegisteredItemByIds(ids));
    }

    @PostMapping("updateRegisteredItem")
    @ApiOperation(value = "修改挂号项目信息")
    @OperLogAnnotation(business_type = "系统业务-修改挂号项目", operator_type = 1)
    public Result updateRegisteredItem(@RequestBody RegisteredItem registeredItem) {
        return new Result<>(200, "修改成功", registeredItemService.updateRegisteredItem(registeredItem));
    }

    @PostMapping("/getRegisteredItemByRegisteredItemId/{registeredItemId}")
    @ApiOperation(value = "根据挂号项目Id查询到一个挂号项目")
    public Result<RegisteredItem> getRegisteredItemByRegisteredItemId(@PathVariable Long registeredItemId) {
        return new Result<RegisteredItem>(200, "查询成功", registeredItemService.getRegisteredItemById(registeredItemId));
    }

    @PostMapping("/addRegisteredItem")
    @ApiOperation(value = "添加挂号项目")
    @OperLogAnnotation(business_type = "系统业务-添加挂号项目", operator_type = 1)
    public Result<Integer> addRegisteredItem(RegisteredItem registeredItem) {
        return new Result<>(200, "添加成功", registeredItemService.addRegisteredItem(registeredItem));
    }
}